<template>
  <div class="home">
    <el-col class="header">
      <el-link @click="$router.push('/')" :underline="false">返回上一页</el-link>
    </el-col>
    <el-col :span="22" style="margin: 70px auto">
      <el-carousel indicator-position="outside" height="400px">
        <el-carousel-item v-for="item in 4" :key="item">
          <h3 text="2xl" justify="center">{{ item }}</h3>
        </el-carousel-item>
      </el-carousel>
    </el-col>

    <el-col v-for="item in indexData" :key="item.type_id" style="margin-top: 30px">
      <el-card style="width: 99%;margin: 0 auto">
        <el-col>
          <span style="font-size: 50px;color: #99a9bf;padding-left: 30px">{{ item.type_name }}</span>
        </el-col>

        <el-col style="display: flex;justify-content: space-around;align-items: center;flex-wrap: wrap">
          <el-col :span="4" v-for="it in item.videoList" :key="it.vod_id" style="margin-left: 20px;margin-top: 20px">
            <el-card shadow="hover" style="height: 405px" @click="videoItemMessage(it.videoItem)">
              <el-col style="height: 300px">
                <el-image style="height: 100%" :src="it.videoItem.vod_pic"></el-image>
              </el-col>
              <el-col style="height: 105px;text-overflow: ellipsis;overflow: hidden">
                <span style="text-align: start;color: #534141;padding-top: 10px">{{ it.vod_name }}</span><br/>
                <span
                    style="overflow: hidden;text-overflow: ellipsis;font-size: 12px">{{ it.videoItem.vod_content }}</span>
              </el-col>
            </el-card>
          </el-col>
        </el-col>
      </el-card>

    </el-col>
  </div>
</template>

<script>
import api from "@/axios/api";

export default {
  name: "HomeView",
  data() {
    return {
      indexData: {}
    }
  },
  methods: {
    videoItemMessage(videoItem) {
      console.log(videoItem);
      this.$router.push({
        name: 'videoItem',
        query: {
          videoItem: JSON.stringify(videoItem),
          from: 'home'
        }
      })
    }
  },
  mounted() {
    api.getIndexData().then(res => {
      console.log(res);
      this.indexData = res.data
    })
  }
};
</script>
<style>
.header{
  /*style="height: 60px;box-shadow: #C0C4CC"*/
  height: 60px;
  position: fixed;
  z-index: 10;
  background-color: rgba(36, 36, 36, 0.78);
  width: 100%;
  top: 0;
}

.el-carousel__item h3 {
  color: #475669;
  opacity: 0.75;
  line-height: 200px;
  margin: 0;
  text-align: center;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n + 1) {
  background-color: #d3dce6;
}

::-webkit-scrollbar {
  width: 6px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background-color: white;
  border-radius: 3px;
}


::-webkit-scrollbar-thumb {
  background-color: #C0C4CC;
  border-radius: 3px;
}

</style>
